"""
系统信息相关API
"""
from flask import Blueprint, request
from app.services.system_service import SystemService
from app.utils.response import success_response, error_response
from datetime import datetime
import logging

logger = logging.getLogger(__name__)
system_bp = Blueprint('system', __name__)


@system_bp.route('/health')
def health():
    """健康检查接口"""
    return success_response("系统运行正常", {
        "status": "ok",
        "timestamp": datetime.now().isoformat(),
        "service": "ERP Mock Server",
        "version": "2.0.0"
    })


@system_bp.route('/yonbip/system/info', methods=['GET'])
def system_info():
    """系统信息"""
    try:
        info = SystemService.get_system_info()
        return success_response("系统信息获取成功", info)
    except Exception as e:
        logger.error(f"获取系统信息异常: {str(e)}")
        return error_response(f"获取系统信息失败: {str(e)}"), 500